#pragma once

#include <QDialog>
#include <QMultiMap>
#include <QTreeWidgetItem>
#include "mediaitem.h"
#include "piocore.h"

namespace Ui {
    class DuplicatesDialog;
}

class DuplicatesDialog : public QDialog
{
    Q_OBJECT

public:
    explicit DuplicatesDialog(PioCore * core, QList<QSet<MediaItemPtr> > groups, QWidget *parent = 0);
    ~DuplicatesDialog();

private slots:
    void on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
    void on_treeWidget_itemPressed(QTreeWidgetItem *item, int column);

    void on_buttonNewest_pressed();
    void on_buttonKeepAll_pressed();
    void on_buttonBox_accepted();

    void timeout();

private:
    void select(QTreeWidgetItem * item);
    static bool lessFilename(MediaItemPtr a, MediaItemPtr b);

    PioCore * m_core;
    Ui::DuplicatesDialog *ui;
    QList<QSet<MediaItemPtr> > m_groups;
};
